<?php
/**
 * SSHComponent
 *
 * @author fusq
 */
class SSHComponent{

    private $host;
    private $port;
    private $userName;
    private $pwd;
    public function  __construct($host,$port=22,$userName,$pwd) {
        $this->host = $host;
        $this->port = $port;
        $this->userName = $userName;
        $this->pwd = $pwd;
    }

    public function connect(){
        $connection = ssh2_connect($this->host,$this->port);
        if (!$connection) die('Connection failed');
        if (!ssh2_auth_password($connection, $this->userName, $this->pwd)) {
          die('Authentication Failed...');
        }
        echo "ok";
    }
}

?>
